package com.study.async.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import java.util.concurrent.Future;

/**
 * @author : wilbur.yuan
 * @date : 2019-02-20
 */
@Slf4j
@Service
public class AsyncService {

    @Async
    public Future<String> test1() throws InterruptedException {
        log.info("test1 begin");
        Thread.sleep(2000);
        log.info("test1 end");
        return new AsyncResult<>("test1") ;
    }

    @Async
    public Future<String> test2() throws InterruptedException {
        log.info("test2 begin");
        Thread.sleep(2000);
        log.info("test2 end");
        return new AsyncResult<>("test2") ;
    }

    @Async
    public Future<String> test3() throws InterruptedException {
        log.info("test3 begin");
        Thread.sleep(2000);
        log.info("test3 end");
        return new AsyncResult<>("test3") ;
    }
}
